/**
 * @param {string} s
 * @return {character}
 */
 var firstUniqChar = function(s) {
    let res=' ';
    let map=new Map();
    for(let i=0;i<s.length;i++){
        if(!map.has(s[i])){
            map.set(s[i],i);
        }
        else {
            map.set(s[i],-1)
        }
    }
    let location=s.length;
    map.forEach((val,key)=>{
        if(val!=-1 && val<location){
            location = val;
            res=key;
        }
    })
    console.log(map)
    return res;
};

console.log(firstUniqChar('eelistt'))